package com.usian.article.controller.v1;


import com.usian.apis.article.ArticleHomeControllerApi;
import com.usian.article.service.ApArticleService;
import com.usian.model.article.dtos.ArticleHomeDto;
import com.usian.model.common.constants.ArticleConstans;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/v1/article")
public class ArticleHomeController implements ArticleHomeControllerApi {
    @Autowired
    private ApArticleService apArticleService;

    @Override
    @PostMapping("load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto) {
        return apArticleService.loadHotArticle(dto, ArticleConstans.LOADTYPE_LOAD_MORE,true);
    }

    @Override
    @PostMapping("loadMore")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(dto,ArticleConstans.LOADTYPE_LOAD_MORE);
    }

    @Override
    @PostMapping("Newload")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto dto) {
        return apArticleService.load(dto,ArticleConstans.LOADTYPE_LOAD_NEW);
    }
}
